package p2pcdnsim.xml;

import java.util.Iterator;

import org.jdom.Document;
import org.jdom.Element;


public class StandardXMLHandler implements XMLHandler {

	private Document doc;

	public StandardXMLHandler(Document doc) {
		this.doc = doc;
	}


	@SuppressWarnings("unchecked")
	public Iterator<Element> iterator() {
		return new StandardIterator(this.doc.getRootElement().getChildren().iterator());
	}
	
	private class StandardIterator implements Iterator<Element> {
		
		Iterator<Element> it;
		
		StandardIterator(Iterator<Element> it) {
			this.it = it;
		}

		@Override
		public boolean hasNext() {
			return it.hasNext();
		}

		@Override
		public Element next() {
			return it.next();
		}

		@Override
		public void remove() {
			it.remove();
		}
	}

}
